<template>
  <div id="chooseOpponent">
    <div class="query" style="background: rgba(53,58,58,0.15)">
      <!-- --------------- -->  
      <div class="homeTitle admin">
        <span>选择交易对手</span>
        <el-input placeholder="搜索交易机构全称" v-model="full" class="input-with-select">
          <el-button slot="append" icon="el-icon-search" @click="searchData()"></el-button>
        </el-input>
      </div>
      <div class="queryCon">
        <div class="qSeles">
          <!-- 两个选择 -->
          <div class="xuanze">
            <div class="xuanzeCon">
              <span>交易对手所在省份：</span>
              <el-select v-model="provice" placeholder="请选择" size="small" @change="changeSheng">
                <el-option
                  v-for="item in shengOption"
                  :key="item"
                  :label="item"
                  :value="item"
                ></el-option>
              </el-select>
            </div>
            <div class="xuanzeCon">
              <span>交易对手所在地市：</span>
              <el-select v-model="city" placeholder="请选择" size="small">
                <el-option
                  v-for="item in shiOption"
                  :key="item"
                  :label="item"
                  :value="item"
                ></el-option>
              </el-select>
            </div>
            <div class="xuanzeCon">
              <span>交易对手机构类型：</span>
              <el-select v-model="type" placeholder="请选择" size="small">
                <el-option
                  v-for="item in jglx"
                  :key="item"
                  :label="item"
                  :value="item"
                ></el-option>
              </el-select>
            </div>
      
          </div>
          <!-- 按钮 -->
          <div class="btnAb">
            <el-button type="primary" size="small" @click="getOpponentList">查询</el-button>
          
          </div>
        </div>
      </div>
    </div>
    <!-- 表格 -->
    <div class="table">
      <!-- 表格 -->
      <div class="tablecon">
        <el-table :data="tableData" border style="width: 100%">
          <el-table-column prop="identification" label="机构标识"  align="center"></el-table-column>
          <el-table-column prop="type" label="交易机构类型" align="center"></el-table-column>
          <el-table-column prop="simple" label="交易机构简称" align="center"></el-table-column>
          <el-table-column prop="full" label="交易机构全称" align="center"></el-table-column>
          <el-table-column prop="phone" label="联系方式" align="center"></el-table-column>
          <el-table-column prop="creditLine" label="统一授信额度(万元)" align="center"></el-table-column>
          <el-table-column prop="available" label="当前可用额度(万元)" align="center"></el-table-column>
          <el-table-column prop="state" label="当前状态"  :formatter="selectStatus" align="center"></el-table-column>
          <el-table-column prop="address" label="操作"   align="center" width="172">
            <template slot-scope="scope">
              <el-button size="mini" type="text" @click="lookDetail(scope.row)">查看详情</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 分页 -->
      <div class="pgfy">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="10"
          layout="total, prev, pager, next, jumper"
          :total="totalPage">
        </el-pagination>
      </div>
      <el-button style="display: block;margin: 0 auto" type="primary" @click="goback">取消</el-button>
    </div>
  </div>
</template>

<script>
import cityData from '../../../assets/js/city.js';
export default {
  name: "chooseOpponent",
  data() {
    return {
       shengOption: [],
       shiOption:[],
       jglx: ['全部','国有控股商业银行','全国性股份制商业银行','政策性银行','城市商业银行','村镇银行','省外系统内-省级银行业存款类金融机构','省外系统内-地市级银行业存款类金融机构','省外系统内-县级银行业存款类金融机构','省外系统内-其他存款类金融机构','其他银行业存款类金融机构','银行业非存款类金融机构','证券业金融机构','保险业金融机构','交易及结算类金融机构','特殊目的载体金融机构','小额贷款公司','金融控股公司','境内其他金融机构','境外同业'],
      
      
      value: '',
      search: '',

      full: '',
      provice: '',
      city: '',
      type: '',
      tableData: [],
      // 分页
      currentPage: 1,
      totalPage: 0
    };
  },
  created() {
    this.getOpponentList()
    this.getsheng()
  },
  methods: {
      // 分页
    handleSizeChange(val) {
    },
    // 分页
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getOpponentList()
    },
     getsheng () {
      let data = cityData[86];
      for(let k in data) {
        this.shengOption.push(data[k]);
      }
    },
    changeSheng () {
      this.city = '';
      let data = cityData[86];
      let shengKey = '';
      for(let k in data) {
        if(data[k]==this.provice) {
          shengKey = k;
        }
      }
      let shidata = cityData[shengKey];
      this.shiOption = [];
      for(let k in shidata) {
        this.shiOption.push(shidata[k]);
      }
    },
    lookDetail (row) {
      this.$router.push({path: 'opponentAccount', query: {id: row.id}});
    },
    getOpponentList(){
      if(this.type == '全部') {
        this.type = ''
      }
      let data = {
        full: this.full,
        provice: this.provice,
        city: this.city,
        type: this.type,
        state: 1,
        page: this.currentPage,
         
      }
      this.axios.get('counterparty/selectList', {params: this.filterNoneObj(data)}).then((res) => {
        this.tableData = res.data.data
        this.totalPage = res.data.pageInfo.total
      })
    },
    goback() {
        this.$router.go(-1)
    },
    searchData() {
      // 搜索查询
      this.getOpponentList()
    },
    selectStatus(val) {
     
      if(val.state == '1'){
        return '可用'
      }else{
        return '黑名单'
      }
    }
  }
};
</script>

<style lang="scss">

#chooseOpponent {
  color:white;

  .homeTitle {
    &.admin {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 20px;
      border-bottom: 1px solid black;
      .el-input {
        width: 300px;
      }
    }
  }
  .queryCon {
    // background: white;
    padding: 0 20px 20px;
    .qSeles {
      padding-top: 20px;
      .xuanze {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        flex-wrap: wrap;
        .xuanzeCon {
          height: 40px;
          display: flex;
          align-items: center;
          margin-right: 30px;
          .el-input {
            width: 200px;
          }
        }
      }
      .btnAb {
        margin-top: 30px;
        .el-button {
          margin-right: 30px;
        }
      }
    }
  }
   .table {
     padding-top: 40px;
    // background: white;
    .tablecon {
      padding: 20px;
    }
    .pgfy {
      padding: 20px;
      padding-top: 10px;
      text-align: right;
    }
  }
}
</style>
